package com.hitao.util;

import com.hitao.Model.packageModel;

import java.io.File;
import java.util.*;

/**
 * Created by Administrator on 2016/4/5.
 */
public class FileScan {
    public List<packageModel> parseFile(String path) {
        File file = new File(path);
        File[] tempList = file.listFiles();
        List<packageModel> list = new ArrayList<packageModel>();
        //System.out.println("该目录下对象个数：" + tempList.length);
        for (int i = 0; i < tempList.length; i++) {
            if (tempList[i].isFile()) {
                // System.out.println("文     件：" + tempList[i]);
                packageModel pk = new packageModel();
                pk.filename = tempList[i].getName();
                pk.updateTime = new Date(tempList[i].lastModified());
                list.add(pk);
            }
        }
        Collections.sort(list, new Comparator<packageModel>() {
            public int compare(packageModel arg0, packageModel arg1) {
                return arg1.updateTime.compareTo(arg0.updateTime);
            }
        });
        return list;
    }
}
